<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <!-- async函数可以将异步函数变为同步函数 -->
    <script>
        // function print(){
        //     //定时器是异步的
        //     setTimeout(()=>{
        //         console.log("定时器");
        //     },10)
        //     console.log("Hello");
        // }

        //async
        function timeout(ms){
            //resolve是一个函数
            return new Promise((resolve) =>{
                setTimeout(function(){
                    console.log("定时器");
                    resolve();
                })
            })
            
        }
        async function asyncPrint(ms,value){
            //把具有异步操作的代码前面放入：await
            await timeout(ms);
            console.log(value);
        }
        asyncPrint(100,"hello")

        print();
    </script>
</body>
</html>